<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<title>EditUser</title>
</h:head>
<h:body>
	<ui:composition template="/WEB-INF/templates/template.xhtml">
		<ui:define name="title">
		Profil bearbeiten
	</ui:define>
		<ui:define name="content">
			<h:form id="editUserForm">
				<h1>Personalien</h1>
				<table>
					<tr>
						<td><h:outputLabel for="gender" value="Geschlecht *" /></td>
						<td><h:selectOneRadio id="gender"
								value="#{userBean.user.gender}">
								<f:selectItem itemLabel="Männlich" itemValue="M" />
								<f:selectItem itemLabel="Weiblich" itemValue="W" />
							</h:selectOneRadio></td>
					</tr>
					<tr>
						<td><h:outputLabel for="lastname" value="Name *" /></td>
						<td><p:inputText id="lastname"
								value="#{userBean.user.surname}" required="true"
								requiredMessage="Name erforderlich" /> <p:message for="lastname" />
						</td>
					</tr>
					<tr>
						<td><h:outputLabel for="firstname" value="Vorname *" /></td>
						<td><p:inputText id="firstname"
								value="#{userBean.user.firstname}" required="true"
								requiredMessage="Vorname erforderlich" /> <p:message
								for="firstname" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="address" value="Strasse &amp; Nr" /></td>
						<td><p:inputText id="address"
								value="#{userBean.user.address}" /> <p:message for="address" />
						</td>
					</tr>
					<tr>
						<td><h:outputLabel for="zip" value="PLZ/Ort" /></td>
						<td><p:inputText style="width: 12%;" id="zip"
								value="#{userBean.user.zipCode}" /> <p:inputText
								style="width: 32%;" id="city" value="#{userBean.user.location}" />
							<p:message for="city" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="dob" value="Geburtsdatum" /></td>
						<td><p:inputMask id="dob"
								value="#{userBean.user.dateOfBirth}"
								converterMessage="Invalid Date" mask="99.99.9999">
								<f:convertDateTime pattern="dd.MM.yyyy" />
							</p:inputMask> <p:message for="dob" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="phone" value="Telefonnummer " /></td>
						<td><p:inputText id="phone" value="#{userBean.user.phone}" />
							<p:message for="phone" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="email" value="E-Mail *" /></td>
						<td><p:inputText id="email" value="#{userBean.user.email}"
								validatorMessage="Ungültige E-Mail Adresse" required="true"
								requiredMessage="E-Mail Adresse erforderlich">
								<f:validateRegex
									pattern="^\w+[\w-\.]*\@\w+((-\w+)|(\w*))\.[a-z]{2,3}$" />
							</p:inputText> <p:message for="email" /></td>
					</tr>
					<tr>
						<td colspan="2"><h2>Zugangsdaten</h2></td>
					</tr>
					<tr>
						<td><h:outputLabel for="user_name" value="Benutzername" /></td>
						<td><p:inputText id="user_name"
								value="#{userBean.user.username}" required="true"
								requiredMessage="Benutzername muss mind. 5 Zeichen lang sein"
								readonly="true">
								<f:validateLength minimum="5" />
							</p:inputText> <p:message for="user_name" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="pwd1" value="Passwort *" /></td>
						<td><p:password id="pwd1" value="#{userBean.user.password}"
								required="true"
								requiredMessage="Passwort muss mind. 5 Zeichen enthalten"
								redisplay="true" match="pwd2"
								validatorMessage="Passwörter stimmen nicht überein">
								<f:validateLength minimum="5" />
							</p:password> <p:message for="pwd1" /></td>
					</tr>
					<tr>
						<td><h:outputLabel for="pwd2" value="Passwort wiederholen *" /></td>
						<td><p:password id="pwd2" value="#{userBean.pwConfirm}"
								required="true"
								requiredMessage="Passwort muss mind. 5 Zeichen enthalten"
								redisplay="true">
								<f:validateLength minimum="5" />
							</p:password> <p:message id="confError" for="pwd2" /></td>
					</tr>
				</table>
				<table>
					<tr>
						<td colspan="2"><p:commandButton id="save_user"
								action="#{userBean.saveUser(userBean.user)}" value="Save"
								ajax="false" /> <p:commandButton id="reset" type="reset"
								value="Zurücksetzen" /></td>
					</tr>
				</table>

			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>